﻿using _18自引用的组织结构树.EntityClass;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace _18自引用的组织结构树.EntityClassConfig;

public class TeacherConfig:IEntityTypeConfiguration<Teacher>
{
    public void Configure(EntityTypeBuilder<Teacher> builder)
    {
        builder.ToTable("T_Teachers");
        builder.HasMany<Student>(t => t.Students).WithMany(s => s.Teachers)
            .UsingEntity(j => j.ToTable("T_Teachers_Students"));
    }
}